import React, { useState, useRef } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
import { SearchTableListItem } from './data';
import versionSearch from '../funcs/versionsearch';
import svnlist from '../funcs/svnlist';


const TableList: React.FC<{}> = () => {
  const actionRef = useRef<ActionType>();
  const request = async () => {
    return await svnlist({})
  };
  const columns: ProColumns<SearchTableListItem>[] = [
    {
      title: "文件名称",
      dataIndex: 'file_name',
      valueType: 'cascader',
      request,
    },
    {
      title: "最新版本号",
      dataIndex: 'version',
      valueType: 'textarea',
      search:false,
    },
  ];

  return (
    <PageContainer>
      <ProTable<SearchTableListItem>
        headerTitle={"查询最新版本"}
        actionRef={actionRef}
        rowKey="key"
        search={{
          labelWidth: 120,
        }}
        request={(params, sorter, filter) => versionSearch({ ...params, sorter, filter })}
        columns={columns}
      />
    </PageContainer>
  );
};

export default TableList;
